<template>
    <div class="editSupplier">
        <el-card>
            <el-button type="info" size="small" icon="el-icon-arrow-left"
                @click="backToPrev">
                返回</el-button>
            <el-form size="small" class="editForm">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item required>
                            <span slot="label">
                                <span class="labelText">类型</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="editForm.type"
                                    placeholder="请选择类型">
                                    <el-option label="公海" value="1"></el-option>
                                    <el-option label="私海" value="0"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商名称</span>
                            </span>
                            <el-input v-model="editForm.name"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商类型</span>
                            </span>
                            <el-input v-model="editForm.providerType"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商级别</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="editForm.level"
                                    placeholder="请选择级别">
                                    <el-option label="1星" value="1"></el-option>
                                    <el-option label="2星" value="2"></el-option>
                                    <el-option label="3星" value="3"></el-option>
                                    <el-option label="4星" value="4"></el-option>
                                    <el-option label="5星" value="5"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商状态</span>
                            </span>
                            <el-input v-model="editForm.intention"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">所属行业</span>
                            </span>
                            <el-input v-model="editForm.industry"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">员工数量</span>
                            </span>
                            <el-input v-model="editForm.employeeNum"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">公司网址</span>
                            </span>
                            <el-input v-model="editForm.webAddr"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">状态</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="editForm.status"
                                    placeholder="请选择状态">
                                    <el-option label="有效" value="0"></el-option>
                                    <el-option label="无效" value="1"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商简拼</span>
                            </span>
                            <el-input v-model="editForm.spell"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商标签</span>
                            </span>
                            <el-input v-model="editForm.tag"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商属性</span>
                            </span>
                            <el-input v-model="editForm.attribute"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商来源</span>
                            </span>
                            <el-input v-model="editForm.source"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">公司性质</span>
                            </span>
                            <el-input v-model="editForm.details"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">营业执照</span>
                            </span>
                            <el-input v-model="editForm.license"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商备注</span>
                            </span>
                            <el-input v-model="editForm.remark"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">联系人</span>
                            </span>
                            <el-input v-model="editForm.contact"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">办公电话</span>
                            </span>
                            <el-input v-model="editForm.officePhone"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">Email</span>
                            </span>
                            <el-input v-model="editForm.email"> </el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">微信</span>
                            </span>
                            <el-input v-model="editForm.wechat"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">手机号码</span>
                            </span>
                            <el-input v-model="editForm.contactPhone"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">传真</span>
                            </span>
                            <el-input v-model="editForm.fax"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">QQ</span>
                            </span>
                            <el-input v-model="editForm.qq"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">旺旺</span>
                            </span>
                            <el-input v-model="editForm.wangwang"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">国家</span>
                            </span>
                            <el-input v-model="editForm.nation"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">市</span>
                            </span>
                            <el-input v-model="editForm.city"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">地址</span>
                            </span>
                            <el-input v-model="editForm.address"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">省</span>
                            </span>
                            <el-input v-model="editForm.province"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">区</span>
                            </span>
                            <el-input v-model="editForm.area"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">邮编</span>
                            </span>
                            <el-input v-model="editForm.postCode"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item class="subBtn">
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                    <el-button @click="backToPrev">取消</el-button>
                </el-form-item>
            </el-form>

        </el-card>

    </div>
</template>
  
<script>


import dayjs from 'dayjs'

export default {
    name: '',
    data() {
        return {
            //绑定数据
            editForm: {
                "address": "string",
                "area": "string",
                "attribute": "string",
                "city": "string",
                "companyCreateTime": "2023-02-20T10:13:07.611Z",
                "contact": "string",
                "contactPhone": "string",
                "createTime": "2023-02-20T10:13:07.611Z",
                "details": "string",
                "email": "string",
                "employeeNum": 0,
                "fax": "string",
                "id": 0,
                "industry": "string",
                "intention": "string",
                "level": 0,
                "license": "string",
                "name": "string",
                "nation": "string",
                "nature": "string",
                "officePhone": "string",
                "postCode": "string",
                "providerType": "string",
                "province": "string",
                "qq": "string",
                "remark": "string",
                "source": "string",
                "spell": "string",
                "status": 0,
                "tag": "string",
                "type": 0,
                "updateTime": "2023-02-20T10:13:07.611Z",
                "userId": 0,
                "wangwang": "string",
                "webAddr": "string",
                "wechat": "string"
            }
        }
    },
    components: {

    },
    mounted(){
         this.editForm={...this.$route.query};
         console.log(this.editForm);
    },
    methods: {
        dayjs,
        backToPrev() {
            this.$router.push('/supply/supManage')
        },
        async onSubmit() {
            // this.editForm.createTime = dayjs().format("YYYY-MM-DD HH:mm");
            this.editForm.userId=sessionStorage.getItem('userID')
            this.editForm.createTime = new Date(dayjs().format("YYYY-MM-DD HH:mm:ss")).toISOString();
            console.log(this.editForm.createTime);
            let res = await this.$api.supply.updateSupplier(this.editForm)
            console.log(res);
            if (res.data.code === 200) {
                //跳转到列表页面
                this.$router.push('/supply/supManage')
                //提示
                this.$message({
                    message: '恭喜你，修改供应商成功',
                    type: 'success'
                });
            } else {
                //错误信息提示
                this.$message.error('出现错误，修改失败');
            }
        }
    }
}
</script>

<style scoped>
.editSupplier {
    margin: 20px 5px 0;
}

.labelText {
    font-size: 14px;
    font-weight: 600;
    color: #000;
}

hr {
    height: 0px;
    border: 1px solid #6c7b8b;
}

.subBtn {
    text-align: center;
}

.choose>>>.el-select {
    display: block;
}

.choose>>>.el-select .el-input__suffix {
    top: 15px;
}
</style>